First Order Equations: Exact and Non-exact Equations

Edmund Chiang
MATH2351 / 2352 — Boyce & DiPrima §2.3
February 9, 2026

1   Exact Equations

1.1   Motivating Example

We notice immediately that the integration factor method and separation of variables both do not work for the DE

$$2x + y^2 + 2xyy' = 0.$$

On the other hand, we notice that

$$0 = 2x + y^2 + 2xyy' = \frac{d}{dx}(x^2 + xy^2),$$

where $y = y(x)$. Hence

$$x^2 + xy^2 = c$$

for some constant $c$.


1.2   Chain Rule for $\psi(x, y)$

Let us recall the standard chain rule for partial derivatives of $\psi(x, y)$, where $x = x(t)$ and $y = y(t)$:

$$\frac{d\psi}{dt} = \frac{\partial \psi}{\partial x}\frac{dx}{dt} + \frac{\partial \psi}{\partial y}\frac{dy}{dt}$$

Let us now revisit the above example and write

$$\psi(x, y) = x^2 + xy^2.$$

Then we have by chain rule above that

$$0 = \frac{d}{dx}\psi(x, y) = \frac{\partial \psi}{\partial x}\frac{dx}{dx} + \frac{\partial \psi}{\partial y}\frac{dy}{dx} = \frac{\partial \psi}{\partial x} + \frac{\partial \psi}{\partial y}\frac{dy}{dx}$$

which was the calculation for $\psi = x^2 + xy^2$ we have computed above. So the conclusion is

$$\psi(x, y) = c$$

for some constant $c$. We note that if we denote $M(x, y) = \partial\psi/\partial x$ and $N(x, y) = \partial\psi/\partial y$, then we could write the DE $2x + y^2 + 2xyy' = 0$ in the form

$$M(x, y) + N(x, y)\,y'(x) = 0.$$

1.3   Definition of Exact Differential Equations

Definition — Exact Differential Equation

The equation

$$M(x, y) + N(x, y)\,y'(x) = 0 \tag{1}$$

is called exact if it can be integrated as

$$\frac{d}{dx}[\psi(x, \phi)] = 0$$

for $y = \phi(x)$. That is, $\psi(x, y(x)) = c$ for some constant $c$.

Remark — Separable as Special Case

We note that if $M(x, y) = M(x)$ and $N(x, y) = N(y)$ in the above consideration, then the DE becomes

$$M(x) + N(y)\frac{dy}{dx} = 0$$

which was the separable form DE considered earlier. In this case, the exactness of the DE criterion

$$M_y = 0 = N_x$$

holds in an appropriate $R$ automatically. Hence the DE can be integrated.


1.4   Exactness Theorem

Theorem — Test for Exactness

Let $M(x, y)$, $N(x, y)$, $M_y(x, y)$, $N_x(x, y)$ be continuous functions defined in the rectangle $R$: $\alpha < x < \beta$; $\gamma < y < \delta$. Then

$$M(x, y) + N(x, y)\frac{dy}{dx} = 0$$

is exact in $R$ if and only if there is a $\psi = \psi(x, y)$ such that

$$\frac{\partial \psi}{\partial x} = M(x, y), \qquad \frac{\partial \psi}{\partial y} = N(x, y)$$

and

$$\boxed{M_y(x, y) = N_x(x, y)}$$

holds at each point of $R$. The equivalent statement is

$$\frac{\partial^2 \psi}{\partial y\,\partial x} = \frac{\partial^2 \psi}{\partial x\,\partial y},$$

holds at each point of $R$, i.e., the DE can be solved.


1.5   Proof of the Exactness Theorem

Proof.

($\Rightarrow$) Suppose first that the DE (1) is exact, that is, we can find a function $\psi(x, y)$ such that

$$\psi_x = M(x, y), \qquad \psi_y = N(x, y)$$

holds in $R$. But $\psi_x$ and $\psi_y$ are continuous, so

$$\psi_{xy} = \psi_{yx}$$

in $R$. But this is precisely the equation $M_y = N_x$.

($\Leftarrow$) Suppose we now assume $M_y = N_x$. Let us integrate the first equation $\psi_x = M$ with respect to $x$ (keeping $y$ constant). This yields

$$\psi(x, y) = Q(x, y) + h(y) = \int_{x_0}^{x} M(s, y)\,ds + h(y), \qquad \alpha < \alpha_0 < x < \beta_0 < \beta.$$

We differentiate this equation both sides respect to $y$ and ask if the formula:

$$\frac{\partial Q}{\partial y} + h'(y) = N(x, y)$$

holds. This is, if

$$h' = N(x, y) - \frac{\partial Q}{\partial y}.$$

Differentiating the RHS with respect to $x$ yields

$$\frac{\partial N}{\partial x} - \frac{\partial}{\partial x}\frac{\partial Q}{\partial y} = \frac{\partial N}{\partial x} - \frac{\partial}{\partial y}\frac{\partial Q}{\partial x} = \frac{\partial N}{\partial x} - \frac{\partial}{\partial y}M = 0$$

since $M_y = N_x$. Hence

$$0 = \frac{\partial h'(y)}{\partial x}$$

holds and that the above $h'(y)$ and $h(y)$ are indeed functions of $y$ only. Upon integration of the above formula with respect to $y$ yields

$$h(y) = \int N(x, t)\,dt - Q + c,$$

for some constant $c$. We further notice that

$$\psi(x, y) = Q(x, y) + h(y) = Q(x, y) + \int N(x, t)\,dt - Q + c = \int N(x, t)\,dt + c.$$

Hence

$$\frac{\partial \psi}{\partial y} = N(x, y).$$

Since we have found a function $\psi(x, y)$ such that $\psi_x = M(x, y)$, $\psi_y = N(x, y)$, so the original DE is exact.

2   Examples of Exact Equations

2.1   Example: $2x + y^2 + 2xyy' = 0$ (Revisited)

The DE

$$2x + y^2 + 2xy\,y' = 0$$

with

$$M(x, y) = 2x + y^2, \qquad N(x, y) = 2xy,$$

is exact in the whole coordinate plane since

$$\frac{\partial M}{\partial y} = \frac{\partial}{\partial y}(2x + y^2) = 2y,$$

and

$$\frac{\partial N}{\partial x} = \frac{\partial}{\partial x}(2xy) = 2y$$

holds at every point of the $xy$-plane.


2.2   Example: $y\cos x + 2xe^y + (\sin x + x^2 e^y - 1)y' = 0$

Consider the equation

$$y\cos x + 2xe^y + (\sin x + x^2 e^y - 1)\frac{dy}{dx} = 0.$$

It is straightforward to check that

$$\frac{\partial M}{\partial y} = \cos x + 2xe^y = \frac{\partial N}{\partial x},$$

holds everywhere where

$$M(x, y) = y\cos x + 2xe^y, \qquad N(x, y) = \sin x + x^2 e^y - 1.$$

So the theorem asserts that there is a $\psi$ such that

\begin{align} \frac{\partial \psi}{\partial x} &= M = y\cos x + 2xe^y, \tag{2}\\[6pt] \frac{\partial \psi}{\partial y} &= N = \sin x + x^2 e^y - 1. \tag{3} \end{align}

Integrating the equation (2) with respect to $x$ yields

$$\psi(x, y) = y\sin x + x^2 e^y + h(y)$$

where $h(y)$ is a function of $y$ only. Differentiating this $\psi$ with respect to $y$ implies that

$$\psi_y = \sin x + 2e^y + h'(y),$$

so that a comparison with (3) yields

$$h'(y) = -1.$$

That is,

$$h(y) = -y$$

ignoring an integration constant.* We deduce

$$\psi(x, y) = y\sin x + x^2 e^y - y = c$$

where $c$ is a constant.

*Since this constant can be relegated to the constant in the final solution.

Alternative Approach

We leave as an exercise to the readers to verify that one can derive the same solution should one integrate the equation (3) with respect to $y$ instead of integration of (2) with respect to $x$.


2.3   Non-exact Example: $3xy + y^2 + (x^2 + xy)y' = 0$

Consider the equation

$$3xy + y^2 + (x^2 + xy)\,y' = 0.$$

Let

$$M(x, y) = 3xy + y^2, \qquad N(x, y) = x^2 + xy.$$

Then

\begin{align} M_y &= 3x + 2y \\[4pt] &\neq 2x + y = N_x. \end{align}

That is, $\psi_{yx} \neq \psi_{xy}$ so that the DE above is not exact unless at $(x, y) = (0, 0)$. So the DE cannot be integrated so solve for $\psi$.

For suppose that there is such $\psi$, then we would have

$$\frac{\partial \psi}{\partial x} = M = 3xy + y^2,$$

so that

$$\psi(x, y) = \frac{3}{2}x^2 y + xy^2 + h(y)$$

where $h = h(y)$ is a function depends on $y$ only. We also have

$$\frac{\partial \psi}{\partial y} = N = x^2 + xy.$$

But then we must have, combining the two sources of $\psi_y$:

\begin{align} h'(y) &= \psi_y - \Big(\frac{3}{2}x^2 + 2xy\Big) \\[4pt] &= x^2 + xy - \Big(\frac{3}{2}x^2 + 2xy\Big) \\[4pt] &= -\frac{1}{2}x^2 - xy \end{align}

which is not a function of $y$ only, a contradiction to our earlier deduction that $h(y)$ is a function of $y$ only. Hence no such $\psi$ can exist.

3   Integrating Factors for Non-exact Equations

We have just met an example of a DE that is not exact so that it cannot be integrated via the familiar method. However, there is a corresponding integrating factor method (not the same one we encountered earlier).

3.1   Derivation of $\mu(x)$

Suppose that

$$M_y \neq N_x,$$

but there is a $\mu = \mu(x, y)$ such that

$$[\mu(x, y)M(x, y)]_y = [\mu(x, y)N(x, y)]_x.$$

That is, we require

$$0 = [M_y - N_x]\mu + \mu_y M - \mu_x N$$

to hold. But such an integration factor is difficult to find and we resort to assume $\mu(x, y) = \mu(x)$. Then the above requirement simplifies to

$$0 = [M_y - N_x]\mu - \mu_x N$$

or

$$\mu_x N = [M_y - N_x]\mu,$$

and so

$$\boxed{\frac{d\mu}{dx} = \frac{[M_y - N_x]}{N}\mu}$$

This equation for $\mu(x)$ can be solved by separation method if the right hand-side is a function of $x$ only.


3.2   Example: Making $3xy + y^2 + (x^2 + xy)y' = 0$ Exact

Let us consider the non-exact DE

$$3xy + y^2 + (x^2 + xy)\,y' = 0.$$

Recall that

$$M(x, y) = 3xy + y^2, \qquad N(x, y) = x^2 + xy.$$

We check to see if the right hand-side of $\mu_x$ is a function of $x$ only:

\begin{align} \frac{\frac{d\mu}{dx}}{\mu} &= \frac{[M_y - N_x]}{N} = \frac{3x + 2y - (2x + y)}{x^2 + xy} \\[6pt] &= \frac{x + y}{x(x + y)} = \frac{1}{x}, \end{align}

is indeed a function of $x$ only. Moreover, solving the above DE for $\mu$

$$\frac{1}{\mu}\frac{d\mu}{dx} = \frac{1}{x},$$

yields $\mu(x) = x$. Multiplying this $\mu$ on both sides of the original DE:

$$3x^2 y + xy^2 + (x^3 + x^2 y)\,y' = 0.$$

Let

$$\tilde{M} = 3x^2 y + xy^2, \qquad \tilde{N} = x^3 + x^2 y.$$

Then

$$\tilde{M}_y = 3x^2 + 2xy = \tilde{N}_x = 3x^2 + 2xy$$

thus verifying the new DE above is EXACT. It is left as an exercise to check that

$$x^3 y + \frac{1}{2}x^2 y^2 = c,$$

for some constant $c$.


3.3   Integrating Factor $\mu(y)$

Remark — Integrating Factor Depending on $y$

If it turns out that the non-exact DE

$$M + Ny' = 0,$$

has

$$\frac{N_x - M_y}{M} = Q,$$

is a function of $y$ only, that is $\mu(x, y) = \mu(y)$ instead, then one can show that it has an integration factor of the form

$$\mu(y) = e^{\int Q(y)\,dy}.$$

4   Exercises

Exercises — Exact Equations

Determine if the following DEs are exact and solve them if so.

  1. $(4x^3 y^3 - 2xy)\,dx + (3x^4 y^2 - x^2)\,dy = 0$ (Ans. $x^4 y^3 - x^2 y = C$)
  2. $(3e^{3x}y - 2x)\,dx + e^{3x}\,dy = 0$ (Ans. $e^{3x}y - x^2 = C$)
  3. $(\cos y + y\cos x)\,dx + (\sin x - x\sin y)\,dy = 0$ (Ans. $x\cos y + y\sin x = C$)
Exercises — Non-exact Equations

Solve the following non-exact DEs:

  1. $(x^2 + y^2 + x)\,dx + xy\,dy = 0$ (Ans. $3x^4 + 4x^3 + 6x^2 y^2 = C$)
  2. $(2xy^4 e^y + 2xy^3 + y)\,dx + (x^2 y^4 e^y - x^2 y^2 - 3x)\,dy = 0$ (Ans. $x^2 e^y + x^2/y + x/y^3 = C$)

5   Practice MCQ

Practice 1: Test for Exactness (Three-Phase Approach)

Given the differential equation:

$$y\cos x + 2xe^y + (\sin x + x^2 e^y - 1)\frac{dy}{dx} = 0$$
PHASE 0 Identify M and N

In the form $M + N\frac{dy}{dx} = 0$, identify $M(x,y)$ and $N(x,y)$:

Good! Now let's test for exactness...
PHASE A Test for Exactness

What condition must we check for exactness?

Compute $M_y = \frac{\partial}{\partial y}(y\cos x + 2xe^y)$:

Compute $N_x = \frac{\partial}{\partial x}(\sin x + x^2 e^y - 1)$:

Compare $M_y$ and $N_x$. Is the equation exact?

The equation is exact! Now let's find $\psi(x,y)$...
PHASE B Find $\psi(x,y)$
Step B1

We need $\psi_x = M = y\cos x + 2xe^y$. Integrating with respect to $x$:

Step B2

Now differentiate $\psi = y\sin x + x^2 e^y + h(y)$ with respect to $y$:

Step B3

We need $\psi_y = N = \sin x + x^2 e^y - 1$. Comparing with $\psi_y = \sin x + x^2 e^y + h'(y)$:

Step B4

Final solution $\psi(x,y) = c$:

Excellent! You've successfully solved the exact equation: $y\sin x + x^2 e^y - y = c$.
Practice 2: Is This Equation Exact?

Determine if the following DE is exact:

$$(3xy + y^2) + (x^2 + xy)\frac{dy}{dx} = 0$$
Step 1

Identify $M$ and $N$:

Step 2

Compute $M_y$:

Step 3

Compute $N_x$:

Step 4

Is the equation exact?

Correct! The equation is NOT exact. We need an integrating factor to solve it.
Practice 3: Find an Integrating Factor (Three-Phase Approach)

Find an integrating factor for the non-exact DE:

$$(3xy + y^2) + (x^2 + xy)\frac{dy}{dx} = 0$$

(We showed this is not exact since $M_y = 3x + 2y \neq 2x + y = N_x$)

PHASE 0 Strategy Selection

To find an integrating factor $\mu$, we first try $\mu = \mu(x)$. What must we check?

Good! Let's compute...
PHASE A Check the Condition

Compute $M_y - N_x$:

Compute $\dfrac{M_y - N_x}{N} = \dfrac{x + y}{x^2 + xy}$:

Since $\frac{M_y - N_x}{N} = \frac{1}{x}$ depends only on $x$, we can find $\mu(x)$. What equation does $\mu$ satisfy?

Now let's solve for $\mu(x)$...
PHASE B Find $\mu(x)$
Step B1

Solve $\frac{1}{\mu}\frac{d\mu}{dx} = \frac{1}{x}$ by integrating both sides:

Step B2

Multiply the original DE by $\mu = x$. What is the new $\tilde{M}$?

Step B3

What is the new $\tilde{N}$?

Step B4

Verify exactness: compute $\tilde{M}_y$ and $\tilde{N}_x$:

The integrating factor is $\mu(x) = x$. The solution (found by solving the now-exact equation) is $x^3 y + \frac{1}{2}x^2 y^2 = c$.
Practice 4: Solve an Exact Equation

Solve the exact equation (from Exercise 1):

$$(4x^3 y^3 - 2xy)\,dx + (3x^4 y^2 - x^2)\,dy = 0$$
PHASE 0 Verify Exactness

With $M = 4x^3 y^3 - 2xy$ and $N = 3x^4 y^2 - x^2$, verify $M_y = N_x$:

Confirmed exact! Let's find $\psi$...
PHASE A Find $\psi(x,y)$

Integrate $\psi_x = M = 4x^3 y^3 - 2xy$ with respect to $x$:

Differentiate $\psi = x^4 y^3 - x^2 y + h(y)$ with respect to $y$ and compare with $N$:

Since $h'(y) = 0$, we have $h(y) = $ constant. The solution $\psi = c$ is:

The solution is $x^4 y^3 - x^2 y = C$.

— End of Exact and Non-exact Equations Notes —